﻿using Company.Database.Entities;
using Company.Database.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Company.Database.Sqlite.Repositories
{
    class UserRepository : IUserRepository
    {
        SqliteDbContext db = new SqliteDbContext();

        public int Delete(User entity)
        {
            db.Entry(entity).State = Microsoft.EntityFrameworkCore.EntityState.Deleted;
            return db.SaveChanges();
        }

        public List<User> GetAll()
        {
            return db.Users.ToList();
        }

        public int Insert(User entity)
        {
            db.Users.Add(entity);
            return db.SaveChanges();
        }

        public int Update(User entity)
        {
            db.Entry(entity).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            return db.SaveChanges();
        }
    }
}
